import turtle
import time

# 设置画布
screen = turtle.Screen()
screen.title("Kobe Bryant")
screen.bgcolor("#f0f0f0")

# 创建绘图对象
kobe = turtle.Turtle()
kobe.speed(3)  # 绘图速度
kobe.pensize(3)

# 绘制头部
def draw_head():
    kobe.penup()
    kobe.goto(0, 100)
    kobe.pendown()
    kobe.begin_fill()
    kobe.circle(60)  # 头部轮廓
    kobe.end_fill()

# 绘制身体和球衣
def draw_body():
    # 躯干
    kobe.penup()
    kobe.goto(0, 40)
    kobe.pendown()
    kobe.setheading(270)
    kobe.forward(100)
    kobe.setheading(0)
    kobe.forward(50)
    kobe.setheading(90)
    kobe.forward(100)
    kobe.setheading(180)
    kobe.forward(100)
    kobe.setheading(90)
    kobe.forward(100)
    kobe.setheading(0)
    kobe.forward(50)
    
    # 球衣号码24
    kobe.penup()
    kobe.goto(-25, -10)
    kobe.pendown()
    kobe.color("white")
    kobe.pensize(5)
    
    # 数字2
    kobe.setheading(0)
    kobe.forward(15)
    kobe.setheading(270)
    kobe.forward(20)
    kobe.setheading(180)
    kobe.forward(15)
    kobe.setheading(90)
    kobe.forward(10)
    kobe.setheading(0)
    kobe.forward(10)
    
    # 数字4
    kobe.penup()
    kobe.goto(10, -10)
    kobe.pendown()
    kobe.setheading(90)
    kobe.forward(20)
    kobe.setheading(0)
    kobe.forward(15)
    kobe.setheading(270)
    kobe.forward(10)
    kobe.setheading(180)
    kobe.forward(15)
    kobe.setheading(270)
    kobe.forward(10)
    
    kobe.pensize(3)
    kobe.color("black")

# 绘制手臂
def draw_arms():
    # 左臂
    kobe.penup()
    kobe.goto(-50, 20)
    kobe.pendown()
    kobe.setheading(180)
    kobe.forward(60)
    kobe.setheading(270)
    kobe.forward(20)
    
    # 右臂
    kobe.penup()
    kobe.goto(50, 20)
    kobe.pendown()
    kobe.setheading(0)
    kobe.forward(60)
    kobe.setheading(270)
    kobe.forward(20)

# 绘制腿部
def draw_legs():
    # 左腿
    kobe.penup()
    kobe.goto(-20, -60)
    kobe.pendown()
    kobe.setheading(270)
    kobe.forward(60)
    kobe.setheading(180)
    kobe.forward(20)
    
    # 右腿
    kobe.penup()
    kobe.goto(20, -60)
    kobe.pendown()
    kobe.setheading(270)
    kobe.forward(60)
    kobe.setheading(0)
    kobe.forward(20)

# 绘制篮球
def draw_basketball():
    kobe.penup()
    kobe.goto(110, -40)
    kobe.pendown()
    kobe.color("orange")
    kobe.begin_fill()
    kobe.circle(20)
    kobe.end_fill()
    
    # 篮球纹路
    kobe.penup()
    kobe.goto(110, -40)
    kobe.pendown()
    kobe.color("black")
    kobe.setheading(0)
    kobe.circle(20, 180)
    kobe.penup()
    kobe.goto(110, -60)
    kobe.pendown()
    kobe.setheading(45)
    kobe.forward(28)
    kobe.penup()
    kobe.goto(110, -60)
    kobe.pendown()
    kobe.setheading(135)
    kobe.forward(28)

# 绘制签名和号码
def draw_signature():
    kobe.penup()
    kobe.goto(-100, -150)
    kobe.pendown()
    kobe.color("purple")
    kobe.write("Kobe Bryant", font=("Arial", 16, "bold"))
    
    kobe.penup()
    kobe.goto(-30, -180)
    kobe.pendown()
    kobe.color("gold")
    kobe.write("24", font=("Arial", 24, "bold"))

# 组合所有部分
def draw_kobe():
    # 设置颜色
    kobe.color("purple")
    kobe.fillcolor("purple")
    
    draw_head()
    draw_body()
    draw_arms()
    draw_legs()
    draw_basketball()
    draw_signature()
    
    # 隐藏画笔
    kobe.hideturtle()

# 执行绘制
draw_kobe()

# 停留一段时间后关闭窗口
time.sleep(10)
turtle.done()
